/*
 * Wantmore - Service Delivery Platform.
 *
 * $Id: PhotoAlbumBindingInitializer.java 53 2010-10-11 12:13:05Z alexey.batyuta@gmail.com $
 *
 * Copyright 2010 by Sunbay Software Crimea Ltd.
 * All rights reserved
 */
package ua.crimea.bat.ss.forms;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;
import ua.crimea.bat.ss.services.PhotoAlbumsService;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * User: bat
 * Date: Mar 26, 2010
 * Time: 9:41:44 AM
 */
public class PhotoAlbumBindingInitializer implements WebBindingInitializer {
    @Autowired
    protected PhotoAlbumsService photoAlbumsService;

    public void initBinder(WebDataBinder webDataBinder, WebRequest webRequest) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setLenient(false);
        webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
        webDataBinder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
        //webDataBinder.registerCustomEditor(, ,new ByteArrayPropertyEditor() );
    }
}
